package com.ssy.lingxi.system.dao;

import com.ssy.lingxi.system.entity.RoleMenu;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 角色权限关系表管理
 *
 * @author wrc
 * @date 2020/5/12
 */
@Repository
public interface RoleMenuRepository extends JpaRepository<RoleMenu, Long> {

    boolean existsByRoleId(Long roleId);

    List<RoleMenu> findByRoleId(Long roleId);

    List<RoleMenu> findByMenuId(Long menuId);

    List<RoleMenu> findByRoleIdAndMenuIdIn(Long roleId, List<Long> menuIds);

    @Transactional
    void deleteAllByRoleIdAndMenuIdIn(Long roleId, List<Long> menuIds);
}
